/**
 * Copies the node to the target space.
 */
function main() {
	// get node to move
	var nodeRef = args.node;
	var node = search.findNode(nodeRef);

	// get destination node
	if (args.target) {
		// call service with nodeRef param
		var targetNode = search.findNode(args.target);
	} else {
		var docLibNode = companyhome.childByNamePath("/Sites/" + args.site
				+ "/documentLibrary")

		var targetPath = args.targetPath;

		if (targetPath == "root") {
			// target is doclib
			var targetNode = docLibNode;
		} else {
			// call service with nodePath param
			var targetNode = docLibNode.childByNamePath(args.targetPath);
		}
	}

	// deep copy containers
	if (node.isContainer) {
		model.result = node.copy(targetNode, true).nodeRef.toString();
	} else {
		model.result = node.copy(targetNode).nodeRef.toString();
	}
}

main();